﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Nature.Core.Cache
{
    public abstract class BaseCacheStrategy : BaseCacheStrategy<Object>
    {
        /// <summary>
        ///     参数的名称cacheGroupName请务必不要改变，否在在使用过程中可能会无法找到
        /// </summary>
        /// <param name="cacheGroupName"></param>
        public BaseCacheStrategy(string cacheGroupName, TimeSpan interval)
            : base(cacheGroupName, interval)
        {
        }
    }

    public abstract class BaseCacheStrategy<T>
    {
        private readonly string _cacheGroupName;
        private readonly TimeSpan _interval;

        /// <summary>
        ///     参数的名称cacheGroupName请务必不要改变，否在在使用过程中可能会无法找到
        /// </summary>
        /// <param name="cacheGroupName"></param>
        public BaseCacheStrategy(string cacheGroupName, TimeSpan interval)
        {
            _cacheGroupName = cacheGroupName;
            _interval = interval;
        }

        public virtual string CacheGroupName
        {
            get { return _cacheGroupName; }
        }

        public virtual TimeSpan Interval
        {
            get { return _interval; }
        }

        public abstract void Set(string key, T value);
        public abstract void Set(string key, T value, DateTime expiryTime);
        public abstract object Get(string key);
        public abstract IList<T> FindAll();
        public abstract void Remove(string key);
        public abstract void RemoveAll();
    }
}
